<?php
namespace BoxEdu\Hooks;
class ClassNewTopicHooks extends \HooksController
{

    
			 
							
							//回答问题
							function comment_after_save_classNew(&$params){
								 $topicData=BoxModel("sns_topic")->where(array('id'=>$params['pid']))->find();
									$title=$topicData['title']?$topicData['title']:$topicData['content'];
								 
									$user_data=BoxModel("system_member")->where(array('user_id'=>$params['user_id']))->find();
									/****最后回复用户**/
									BoxModel("sns_topic")->where(array('id'=>$params['pid']))->save(array('lastPostName'=>$user_data['nickname'],'lastupdate'=>time()));
									$url=HomeUrl.U('Subject/topic_info',array('topic_id'=>$params['pid'],'comment_id'=>$params['id']));
								
								/******提醒楼主,有人向你提问了***/
								if($topicData['user_id'] != $this->user_id){
									$NotiParams=array(
											  'user_id'=>$topicData['user_id'],
													'url'=>$url,
													'name'=>$user_data['nickname']?$user_data['nickname']:"有人",
													'title'=>cutstr(htmlspecialchars($title),50),
											);
									Logic("BoxSns","Noti")->send("00008",$NotiParams);
							}
									/*******提醒AT***/
								$user_ids = Logic("BoxSns", "Noti")->At($content); //需要@提醒的用户ID
								unset($user_ids[$this->user_id]);
        if (!empty($user_ids)) {
            $NotiParams=array(
											  'user_id'=>$user_ids,
													'url'=>$url,
													'name'=>$user_data['nickname']?$user_data['nickname']:"有人",
													'title'=>cutstr(htmlspecialchars($title),50),
											);
								  	Logic("BoxSns","Noti")->send("00005",$NotiParams);
        }
								/**********回复提醒****/
							 
								if (!empty($params['to_comment_id']) && $params['to_user_id'] != $this->user_id) {
            $NotiParams=array(
											  'user_id'=>$params['to_user_id'],
													'url'=>$url,
													'name'=>$user_data['nickname']?$user_data['nickname']:"有人",
													'title'=>cutstr(htmlspecialchars($title),50),
											);
										//	dump($NotiParams);
								  	Logic("BoxSns","Noti")->send("00007",$NotiParams);
        }
				
							}
							
							
							
							//评论的pid
							function topic_load_classNew(&$params){
								 $params['pidData']=BoxModel("edu_subject")->where(array('subjectid'=>$params['pid2']))->find();
								//	dump( $params['pidData']);
							}
}
